package com.house.core.exception;
/**
 *
 *
 * @author <a href="mailto:chong.sun@renren-inc.com">sun chong</a>
 * @version 2013-2-22
 */
public class HouseException extends RuntimeException {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5112239451701337652L;
	
	private StringBuilder stringBuilder;
	
	private Throwable cause;
	
	public HouseException(String msg){
		this(msg, null);
	}
	
	public HouseException(String msg, Throwable cause){
		
	}
	
	public HouseException append(String key, Object value){
		stringBuilder.append("key=").append(key).append(",").append("value=").append(value == null ? "null" : value.toString());
		return this;
	}
	
	public static HouseException build(ErrorInfo errorInfo){
		HouseException e = new HouseException(errorInfo.getErrorCode() + "," + errorInfo.getErrorMessage());
		return e;
	}
	
	public static HouseException build(ErrorInfo errorInfo, Throwable cause){
		HouseException e = new HouseException(errorInfo.getErrorCode() + "," + errorInfo.getErrorMessage(), cause);
		return e;
	}
	
	
	public static void main(String[] args) {
		throw HouseException.build(ErrorInfo.SqlError).append("username", "123456");
	}
}
